﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FairyGUI;
using Model;

namespace MDFGame
{
    public static class AreaFactory
    {
        public static Entity CreateArea(AreaType at,Owner o,GComponent areaUI)
        {
            Area _area=EntityFactory.Create<Area>();

            //创建区域信息组件
            AreaInfoComponent _aic = _area.AddComponent<AreaInfoComponent>();
            _aic.AreaType = at;
            _aic.Owner = o;
            _aic.EffectActive = true;
            _aic.IgnoreArea = false;
            AreaUIComponent _auc = _area.AddComponent<AreaUIComponent>();
            _auc.areaType = at;
            if ((int)at <= 9)//AreaType定义 9以下均为与卡牌存在交互，这一类需要创建ACard和Aeffect
            {
                _auc.CanTouch = true;
                AreaCardComponent _acc = _area.AddComponent<AreaCardComponent>();
                switch (at)
                {
                    case AreaType.Deck:
                        _aic.AreaState = AreaState.Public | AreaState.Hide;
                        _aic.AreaValue.Add("CardNums", 0);
                        _auc.UIView = new DeckUI();
                        break;
                    case AreaType.Character:
                        _aic.AreaState = AreaState.Owner | AreaState.Show;
                        _acc.LimitNum = 1;
                        _auc.UIView = new CharacterUI();
                        break;
                    case AreaType.CharacterWait:
                        _aic.AreaState = AreaState.Owner | AreaState.Show;
                        _acc.LimitNum = 2;
                        _auc.UIView = new CharacterWaitUI();
                        break;
                    case AreaType.Drop:
                        _aic.AreaState = AreaState.Public | AreaState.Show;
                        _auc.UIView = new DropUI();
                        break;
                    case AreaType.Except:
                        _aic.AreaState = AreaState.Public | AreaState.Show;
                        _auc.UIView = new ExceptUI();
                        break;
                    case AreaType.Special:
                        _aic.AreaState = AreaState.Owner | AreaState.Hide;
                        _acc.LimitNum = 2;
                        _auc.UIView = new SpecialUI();
                        break;
                    case AreaType.Level:
                        _aic.AreaState = AreaState.Public | AreaState.Show;
                        _auc.UIView = new LevelUI();
                        break;
                    case AreaType.TempCost:
                        _aic.AreaState = AreaState.Public | AreaState.Show;
                        _acc.LimitNum = 5;
                        _auc.UIView = new TempCostUI();
                        break;
                    default:
                        break;
                }
            }
            else//此外并不需要
            {
                _auc.CanTouch = false;
                switch (at)
                {
                    case AreaType.Cost:
                        _aic.AreaValue.Add("MaxCost", 5);
                        _aic.AreaValue.Add("NowCost", 5);
                        _aic.AreaValue.Add("DisableCost", 0);
                        break;
                    case AreaType.Hp:
                        _aic.AreaValue.Add("MaxHp", 10000);
                        _aic.AreaValue.Add("NowHp", 10000);
                        break;
                    default:
                        break;
                }
            }
            _auc.UIView.Create(areaUI, _auc);
            return _area;
        }
    }
}
